
cc.Class({
    extends: cc.Component,

    properties: {
   
    },


     onLoad () {        
        this.speed_bullet = 2;
        this.speed = 2;
     },

     //子弹类型
     init:function(type,rotation){
     this.node.type = type;
     //boss调用条件
      if(this.node.type == 3){
       this.node.rotation = rotation;
       this.speedx = -Math.sin(rotation / 180 * Math.PI)*this.speed;
       this.speedy = -Math.cos(rotation / 180 * Math.PI)*this.speed;
      }
      if(this.node.type == 4){
        this.node.rotation = rotation;
        this.speedx = Math.sin(rotation / 180 * Math.PI)*this.speed;
        this.speedy = Math.cos(rotation / 180 * Math.PI)*this.speed; 
      }
     },

     die:function(){
      this.node.destroy();  
     },

    start () {

    },

     update (dt) {
      if(this.node.type == 3 || this.node.type == 4){
          this.node.x += this.speedx;
          this.node.y += this.speedy;
      }else{
        this.node.y -= this.speed_bullet;  
      }
      
      if(this.node.x <= -cc.winSize.width / 2 ||this.node.x >= cc.winSize.width / 2
         || this.node.y <= -cc.winSize.height / 2){
             this.node.destroy();
         }
     

     },
});
